<template>
  <el-form ref="baseForm" label-position="top" :model="infoData">
    <AgelFormDesc :items="baseItems" :column="4">
      <template #slot-bonus>
        <div class="w-700">
          <ContractBonu readonly v-model="infoData.bonus"></ContractBonu>
          <ContractIncentive readonly ref="contractIncentiveRef" v-model="infoData.incentives">
          </ContractIncentive>
        </div>
      </template>
    </AgelFormDesc>
  </el-form>
</template>

<script setup  lang="tsx">
import { BizContractVo, defaultModel } from '@/api/operation/contract/types'
import ContractBonu from '../common/contract-bonu/index.vue'
import ContractIncentive from '../common/contract-incentive/index.vue'
import { parseTime } from '@/utils/ruoyi'

const props = defineProps({
  info: {
    type: Object as PropType<BizContractVo>,
    default: (): BizContractVo => defaultModel()
  },
})
const infoData = computed((): BizContractVo => {
  return {
    ...props.info,
    validRange: props.info.validFrom && props.info.validTo ? [props.info.validFrom, props.info.validTo] : []
  }
})
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { settle_period_type ,contract_status} = toRefs<any>(proxy?.useDict('settle_period_type','contract_status'));

const baseItems = reactive([
  { prop: "contractNo", label: "合同编号" },
  { prop: "vendorName", label: "酒店名称", },
  { prop: "regionName", label: "省市区", },
  { prop: "vendorUser", label: "联系人", },
  { prop: "vendorPhone", label: "联系人电话", },
  { prop: "signUser", label: "销售负责人" },
  {
    prop: "validRange", label: "合同生效日期",
    viewFormat: ({ modelValue }: any) => {
      return modelValue || modelValue.length ? parseTime(modelValue[0], '{y}-{m}-{d}') + ' ~ ' + parseTime(modelValue[1], '{y}-{m}-{d}') : '-'
    }
  },
  {
    prop: "signTime", label: "签订日期", viewFormat: ({ modelValue }: any) => {
      return parseTime(modelValue, '{y}-{m}-{d}')
    }
  },
  {
    prop: "settlePeriodType", label: "结算周期",
    viewFormat: ({ modelValue }: any) => {
      return (<dict-tag options={settle_period_type.value} value={modelValue} />)
    }
  },
  
  {
    prop: "autoSettleEnabled", label: "是否启用自动结算", span: 1,
    viewFormat: ({ modelValue }: any) => {
      return (<el-switch activeValue='1' inactiveValue='0' value={modelValue} />)
    }
  },
  {
    prop: "status", label: "状态", span: 3,
    viewFormat: ({ modelValue }: any) => {
      return (<dict-tag options={contract_status.value} value={modelValue} />)
    }
  },
  
  {
    prop: "bonusInfo", label: "分佣信息", slot: 'slot-bonus', span: 4
  },
])

onMounted(() => {
})
</script>
